﻿<%@ Page Title="" Language="C#" MasterPageFile="~/DCTEDU_/Admin.Master" AutoEventWireup="true"
    CodeBehind="QLChuyenMuc.aspx.cs" Inherits="UserKTXD.DCTEDU_.QuanLy.QLChuyenMuc" %>

<%@ Register Assembly="PagerControl" Namespace="CutePager" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HomePlaceHolder" runat="server">
    <script type="text/javascript">
        var gridMain = null;
        window.onload = function () {
            try {
                //get target base control.
                gridMain = document.getElementById('<%= this.gridCatalog.ClientID %>');
            }
            catch (err) {
                gridMain = null;
            }
        }
    </script>
    <script src="../../Scripts/QLTinTuc.js" type="text/javascript"></script>
    <div class="hrm_header_placeholder">
        Quản lý Tin Tức</div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div style="padding: 10px;">
                <asp:Panel ID="PanelAdd" Width="100%" GroupingText="Tìm kiếm thông tin" runat="server">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td colspan="4" height="10">
                            </td>
                        </tr>
                        <tr>
                            <td width="20">
                            </td>
                            <td width="110" class="hrm_title_blue">
                                Tiêu đề
                            </td>
                            <td width="7" class="hrm_title_blue">
                                :
                            </td>
                            <td width="220">
                                <asp:TextBox ID="txtTieuDe" CssClass="hrm_textbox" Width="200px" MaxLength="100"
                                    runat="server"></asp:TextBox>
                            </td>
                            <td width="20">
                            </td>
                            <td width="110" class="hrm_title_blue">
                                Loại Chuyên Mục
                            </td>
                            <td width="7" class="hrm_title_blue">
                                :
                            </td>
                            <td>
                                <asp:DropDownList ID="cboLoaiChuyenMuc" AutoPostBack="true" OnSelectedIndexChanged="cboLoaiChuyenMuc_Click"
                                    CssClass="hrm_combobox" Width="205px" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td width="130" class="hrm_title_blue">
                                Sub Chuyên mục
                            </td>
                            <td width="7" class="hrm_title_blue">
                                :
                            </td>
                            <td width="230px">
                                <asp:DropDownList ID="cboSubChuyenMuc" CssClass="hrm_combobox" Width="200px" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:ImageButton ID="cmdTimKiem" ImageUrl="~/Images/tim.jpg" runat="server" OnClick="cmdTimKiem_Click" />
                                <asp:ImageButton ID="cmdTimLai" CausesValidation="false" ImageUrl="~/Images/timlai.jpg"
                                    runat="server" OnClick="cmdTimLai_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" height="4">
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                 <asp:Panel ID="Panel1" Width="100%" GroupingText="Danh sách Chuyên mục Cấp 1" runat="server">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="20">
                            </td>
                            <td style="padding-right: 15px; padding-top: 12px">
                                <asp:GridView ID="grvChuyenMuc" runat="server" DataKeyNames="Id" Width="100%" BackColor="White"
                                    OnRowDataBound="gridCatalog2_RowDataBound" EmptyDataText="<br><center>Không tồn tại dữ liệu</center><br>"
                                    BorderColor="#CCCCCC" AutoGenerateColumns="false" BorderStyle="Solid" BorderWidth="1px"
                                    CellPadding="3">
                                    <Columns>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="STT" ItemStyle-Width="30">
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-Width="30" HeaderText="Chọn">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                                <asp:HiddenField ID="H_IdCatalog" runat="server" Value='<%# Eval("Id") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Tiêu đề tin" ItemStyle-Width="25%">
                                            <ItemTemplate>
                                            <asp:HyperLink ID="linkTin" runat="server" NavigateUrl='<%# "~/ChuyenMuc/"+ Eval("IdLoaiChuyenMuc") + "/" + GetTieuDe(Eval("TieuDe")) + "_" + Eval("Id") + ".aspx"  %>'>
                                               <%# Eval("TieuDe") %></asp:HyperLink>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="TomTat" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%"
                                            HeaderText="Tóm tắt"></asp:BoundField>
                                        <asp:TemplateField HeaderText="Loại Chuyên mục" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-Width="120">
                                            <ItemTemplate>
                                                <asp:Label ID="lblLoaTinTuc" CssClass="ogiua" runat="server" Text='<%# GetLoaiChuyenMuc(Eval("IdLoaiChuyenMuc")) %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="LuotXem" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="5%"
                                            HeaderText="Lượt Xem"></asp:BoundField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Ngày cập nhật" ItemStyle-Width="90">
                                            <ItemTemplate>
                                                <asp:Label ID="LabelNgayCapNhat" runat="server" Text='<%# Convert.ToDateTime(Eval("NgayCapNhat")).ToString("dd/MM/yyyy")%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Đã đăng?" ItemStyle-Width="8%">
                                            <ItemTemplate>
                                                <asp:Label ID="LbTrangThai" runat="server" Text='<%# (Eval("TrangThai").ToString())=="True" ? "<html><img src=../../Images/checkk.png /></html>" : "<html><img src=../../Images/redx.png /></html>"%>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" Width="8%" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle ForeColor="#000066" />
                                    <SelectedRowStyle BackColor="#dedfdf" Font-Bold="True" ForeColor="Gray" />
                                    <HeaderStyle BackColor="#006699" Font-Bold="True" HorizontalAlign="Left" ForeColor="White" />
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" height="10">
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <cc1:Pager ID="Pager2" runat="server" PreviousClause="Lùi" NextClause="Tiến" LastClause=""
                                    FirstClause="" PageClause="Trang " OfClause=" /" PageSize="6" OnCommand="Pager2_Command"
                                    ForeColor="#006600" Font-Bold="True" />
                                <br />
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                <asp:Panel ID="PanelList" Width="100%" GroupingText="Danh sách Chuyên mục cấp 2" runat="server">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="20">
                            </td>
                            <td style="padding-right: 15px; padding-top: 12px">
                                <asp:GridView ID="gridCatalog" runat="server" DataKeyNames="Id" Width="100%" BackColor="White"
                                    OnRowDataBound="gridCatalog_RowDataBound" EmptyDataText="<br><center>Không tồn tại dữ liệu</center><br>"
                                    BorderColor="#CCCCCC" AutoGenerateColumns="false" BorderStyle="Solid" BorderWidth="1px"
                                    CellPadding="3">
                                    <Columns>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="STT" ItemStyle-Width="30">
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-Width="30" HeaderText="Chọn">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                                <asp:HiddenField ID="H_IdCatalog" runat="server" Value='<%# Eval("Id") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="TieuDe" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%"
                                            HeaderText="Tiêu đề tin"></asp:BoundField>
                                        <asp:BoundField DataField="TomTat" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="25%"
                                            HeaderText="Tóm tắt"></asp:BoundField>
                                        <asp:TemplateField HeaderText="Loại Chuyên mục" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-Width="120">
                                            <ItemTemplate>
                                                <asp:Label ID="lblLoaTinTuc" CssClass="ogiua" runat="server" Text='<%# GetLoaiChuyenMuc(Eval("IdLoaiChuyenMuc")) %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Sub Tin tức" HeaderStyle-HorizontalAlign="Center"
                                            ItemStyle-Width="120">
                                            <ItemTemplate>
                                                <asp:Label ID="lblSubTinTuc" CssClass="ogiua" runat="server" Text='<%# GetSubChuyenMuc(Eval("IdSubChuyenMuc")) %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="LuotXem" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="5%"
                                            HeaderText="Lượt Xem"></asp:BoundField>
                                       <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Tác giả" ItemStyle-Width="90">
                                            <ItemTemplate>
                                                <asp:Label ID="LabelTacGia" runat="server" Text='<%# GetTenThanhVien(Eval("IdTacGia"))%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Ngày cập nhật" ItemStyle-Width="90">
                                            <ItemTemplate>
                                                <asp:Label ID="LabelNgayCapNhat" runat="server" Text='<%# Convert.ToDateTime(Eval("NgayCapNhat")).ToString("dd/MM/yyyy")%>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                            HeaderText="Đã đăng?" ItemStyle-Width="5%">
                                            <ItemTemplate>
                                                <asp:Label ID="LbTrangThai" runat="server" Text='<%# (Eval("TrangThai").ToString())=="True" ? "<html><img src=../../Images/checkk.png /></html>" : "<html><img src=../../Images/redx.png /></html>"%>'></asp:Label>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" Width="5%" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle ForeColor="#000066" />
                                    <SelectedRowStyle BackColor="#dedfdf" Font-Bold="True" ForeColor="Gray" />
                                    <HeaderStyle BackColor="#006699" Font-Bold="True" HorizontalAlign="Left" ForeColor="White" />
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" height="10">
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <cc1:Pager ID="Pager1" runat="server" PreviousClause="Lùi" NextClause="Tiến" LastClause=""
                                    FirstClause="" PageClause="Trang " OfClause=" /" PageSize="6" OnCommand="Pager1_Command"
                                    ForeColor="#006600" Font-Bold="True" />
                                <br />
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </div>
            <asp:Panel ID="Panel2" CssClass="div_footer" BackColor="#d6e6f5" runat="server" Height="24px">
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td>
                            <asp:ImageButton ID="cmdTaoMoi" CausesValidation="false" ImageUrl="~/Images/taomoi.jpg"
                                PostBackUrl="~/DCTEDU_/QuanLy/CNChuyenMuc.aspx" runat="server" />
                            <asp:ImageButton ID="cmdHieuChinh" CausesValidation="false" OnClientClick="return HieuChinh_TinTuc();"
                                ImageUrl="~/Images/hieuchinh.jpg" runat="server" OnClick="cmdHieuChinh_Click" />
                            <asp:ImageButton ID="cmdXoa" CausesValidation="false" OnClientClick="return Xoa_TinTuc();"
                                ImageUrl="~/Images/xoa.jpg" runat="server" OnClick="cmdXoa_Click" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="cmdHieuChinh" />
            <asp:AsyncPostBackTrigger ControlID="cmdXoa" />
            <asp:AsyncPostBackTrigger ControlID="cmdTimKiem" />
            <asp:AsyncPostBackTrigger ControlID="cmdTimLai" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
